<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8" />
    <title>审批记录状态修复</title>
    <script th:src="@{/js/jquery.js}"></script>

</head>
<body>

<form name="billInfo">
	<table width="100%">
		<tr>
    		<td align="center"><h1>审批记录状态修复</h1></td>
    	</tr>
    </table>
    <table>
        <tr>
            <td>BusinessID:</td>
            <td>
            	<input id="businessId" type="text" name="businessId" style="width: 320px" />
            </td>
            <td colspan="2">
                <input type="button" value="查询" onclick="query()" />
            </td>
            <td>
            	<input id="tempBusinessId" type="hidden"  value="value"/>
            </td>
        </tr>
        <tr>
        	<td>审批状态:</td>
        	<td>
        		<select id="statusId" name = "status">
  					<option value ="9">已作废</option>
  					<option value ="12">待处理</option>
  					<option value ="20">处理中</option>
  					<option value ="21">已完成</option>
				</select>
			</td>
			<td colspan="2">
                <input id="StatusRepair" type="button" value="状态修复" disabled="true" onclick="statusRepair()" />
            </td>
		</tr>

    </table>
	<div>
    	<hr>
	</div>
    <div id="result">
    </div>
</form>
</body>


<script type="text/javascript">


     //   $(document).ready(function(){
            function query(){
                var businessId = billInfo.businessId.value;
                if(businessId == ''){
               		alert('请输入流水号！');
              		return false;
                }
                $.post("/select",
                {"businessId":businessId},
                function(data){
                	$("#result").empty();
                	if(data){
                		var html="<table border='1' cellspacing='0'><tr><td width='180px'><h4>流水号</h4></td>"
                			html+="<td width='80px'><h4>广场ID</h4></td>"
                			html+="<td width='80px'><h4>品牌id</h4></td>"
                			html+="<td><h4>品牌名称</h4></td>"
                			html+="<td width='80px'><h4>设备id</h4></td>"
                			html+="<td width='75px'><h4>操作类型</h4></td>"
                			html+="<td width='50px'><h4>修改前状态</h4></td>"
                			html+="<td width='50px'><h4>修改后状态</h4></td>"
                			html+="<td width='85px'><h4>充值金额</h4></td>"
                			html+="<td width='50px'><h4><font color='red'>状态</font></h4></td>"
                			html+="<td><h4>发起人</h4></td>"
                			html+="<td><h4>审批人</h4></td>"
                			html+="<td><h4>充值理由说明</h4></td>"
                			html+="<td><h4>处理次数</h4></td>"
                			html+="<td><h4>审批说明</h4></td>"
                			html+="<td><h4>紧急程度</h4></td>"
                			html+="<td width='90px'><h4>最后一次更新时间</h4></td>"
                        	html+="<td width='90px'><h4>创建时间</h4></td></tr>"
                			html+="<tr><td>"+data.businessId+"</td>"
                        	html+="<td>"+data.plazaId+"</td>"
                        	html+="<td>"+data.brandId+"</td>"
                        	html+="<td>"+data.brandName+"</td>"
                        	html+="<td>"+data.deviceId+"</td>"
                        	html+="<td>"+data.operateName+"</td>"
                        	html+="<td>"+data.oldStatus+"</td>"
                        	html+="<td>"+data.newStatus+"</td>"
                        	html+="<td>"+data.rechargeMoney+"</td>"
                        	html+="<td>"+data.approveName+"</td>"
                        	html+="<td>"+data.operatorName+"</td>"
                        	html+="<td>"+data.approverName+"</td>"
                        	html+="<td>"+data.rechargeMoneyReason+"</td>"
                        	html+="<td>"+data.tryTimes+"</td>"
                        	html+="<td>"+data.approveDesc+"</td>"
                        	html+="<td>"+data.urgentOrder+"</td>"
                        	html+="<td>"+data.launchUpdateTimeStr+"</td>"
                        	html+="<td>"+data.createTimeStr+"</td>"
                     		html+="</tr></table>"
                    	$("#result").append(html);
                     	document.getElementById("tempBusinessId").setAttribute('value', data.businessId);// 隐藏属性赋值
                     	var osel=document.getElementById("statusId"); //得到select的ID
                     	var opts=osel.getElementsByTagName("option");//得到数组option
                     	if(data.approveType==12){
                     		opts[1].selected=true;
                     	}
                     	else if(data.approveType==20){
                     		opts[2].selected=true;
                     	}
                     	else if(data.approveType==21){
                     		opts[3].selected=true;
                     	}
                     	else{
                     		opts[0].selected=true;
                     	}
                		document.getElementById("StatusRepair").removeAttribute("disabled");// 按钮设置可点击
                	}
                	else{
                		var html="<h3>流水号:<font color='red'>"+businessId+"</font>不存在，请仔细检查！</h3>"
                		$("#result").append(html);
                		document.getElementById("StatusRepair").setAttribute("disabled", true);//设置不可点击
                	}
                });
            }

            function statusRepair(){
                var businessId = billInfo.tempBusinessId.value;
                var approveType = billInfo.status.value;
                if(businessId != billInfo.businessId.value){
                	alert("请先点击查询按钮，再进行修复！");
                }
                else{
                	$.post("/status_Repair",
                    {"businessId":businessId, "approveType":approveType},
                    function(data){
                        if(data == 1){
                            alert("修复成功！");
                            query();
                        }
                        else {
                            alert("修复失败！");
                        }

                    });
                }
            }

    //    });
</script>
</html>